public class PlainTextTeamFormatter implements TeamFormatter{

    private static volatile PlainTextTeamFormatter singletonInstance = null;

    private PlainTextTeamFormatter() {
    }

    public static synchronized PlainTextTeamFormatter getSingletonInstance(){
        if(singletonInstance == null){
            singletonInstance = new PlainTextTeamFormatter();
        }
        return singletonInstance;
    }

    @Override
    public String formatTeam(Team team) {
        StringBuilder sb = new StringBuilder();

        sb.append("Team{" + "\n").
                append("\tteamId : " + team.getTeamId() + "\n").
                append("\tteamName : " + team.getTeamName() + "\n").
                append("\tdepartment : " + team.getDepartment() + "\n").
                append("\tcreator{" + "\n").
                    append("\t\tid : " + team.getCreator().getId() + "\n").
                    append("\t\tname : " + team.getCreator().getName() + "\n").
                    append("\t\tphoneNo : " + team.getCreator().getPhoneNo() + "\n").
                    append("\t\temail : " + team.getCreator().getEmail() + "\n").
                    append("\t\tstudentNo : " + team.getCreator().getStudentNo() + "\n");
                    if(team.getCreator().getGender()){
                        sb.append("\t\tgender : " + "女" + "\n");
                    }else{
                        sb.append("\t\tgender : " + "男" + "\n");
                    }
                    sb.append("\t\tgrade : " + team.getCreator().getGrade() + "\n").
                    append("\t\tdepartment : " + team.getCreator().getDepartment() + "\n").
                append("\t}" + "\n").
                append("\tstudentList{" + "\n");
                    for (Student student:team.getStudentList()) {
                        sb.append("\t\tstudent{" + "\n").
                                append("\t\t\tid : " + student.getId() + "\n").
                                append("\t\t\tname : " + student.getName() + "\n").
                                append("\t\t\tphoneNo : " + student.getPhoneNo() + "\n").
                                append("\t\t\temail : " + student.getEmail() + "\n").
                                append("\t\t\tstudentNo : " + student.getStudentNo() + "\n");
                                if(student.getGender()){
                                    sb.append("\t\t\tgender : " + "女" + "\n");
                                }else{
                                    sb.append("\t\t\tgender : " + "男" + "\n");
                                }
                                sb.append("\t\t\tgrade : " + student.getGrade() + "\n").
                                append("\t\t\tdepartment : " + student.getDepartment() + "\n");
                        sb.append("\t\t}" + "\n");
                    }
                sb.append("\t}" + "\n");
                sb.append("\tteacherList{" + "\n");
                    for (Teacher teacher:team.getTeacherList()) {
                        sb.append("\t\tteacher{" + "\n").
                                append("\t\t\tid : " + teacher.getId() + "\n").
                                append("\t\t\tname : " + teacher.getName() + "\n").
                                append("\t\t\tphoneNo : " + teacher.getPhoneNo() + "\n").
                                append("\t\t\temail : " + teacher.getEmail() + "\n").
                                append("\t\t\tteacherNo : " + teacher.getTeacherNo() + "\n").
                                append("\t\t\tdepartment : " + teacher.getDepartment() + "\n");
                        sb.append("\t\t}" + "\n");
                    }
                sb.append("\t}" + "\n");
        sb.append("}\n");

        return sb.toString();
    }
}
